
<%@page import="java.util.List"%>
<%@page import="com.itwill.ecom.product.ProductBeans"%>
<%@page import="com.itwill.ecom.product.ProductService"%>
<%@page import="com.itwill.ecom.cart.CartBeans"%>
<%@page import="com.itwill.ecom.cart.CartService"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@ page language="java" contentType="text/xml; charset=utf-8"
    pageEncoding="utf-8"%>

<%
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(application);
CartService cartService = (CartService)webApplicationContext.getBean("cartService");
ProductService productService = (ProductService)webApplicationContext.getBean("productService");
int cart_no=Integer.parseInt(request.getParameter("cart_no").trim()); 
System.out.println("############# 카트 토탈 jsp cart_no:"+cart_no);

int total=0;
CartBeans cartBean=cartService.getCart(cart_no);
ProductBeans productBean=productService.getProductByNo(cartBean.getCart_product());
List<CartBeans> list=cartService.getCartListByMemberNo(cartBean.getCart_member());
%>

<%

for(int i=0;i<list.size();i++){
	CartBeans cartbean=list.get(i);
	
	total=total+(cartbean.getCart_count()*productService.getProductByNo(cartbean.getCart_product()).getProduct_price());
	System.out.println("총액 구하는 for문 내부 total:"+total);
}
%>
	<total>
		<cart_total><%=total%></cart_total>
		<cart_no><%=cartBean.getCart_no()%>원</cart_no>
	</total>
